<!DOCTYPE html>
<html lang="zh">
 <head>
 	<#include "${managerViewPath}/include/macro.ftl"/>
  	<#include "${managerViewPath}/include/meta.ftl"/>   
  	<link rel="stylesheet" type="text/css" href="${basePath}/static/plugins/bootstrap.star.rating/star-rating.min.css"></link>
	<script type="text/javascript" src="${basePath}/static/plugins/bootstrap.star.rating/star-rating.min.js"></script>
	<link rel="stylesheet" type="text/css" href="${basePath}/static/plugins/bootstrap-jdt/css/bs-is-fun.css"></link>
	<link rel="stylesheet" type="text/css" href="${basePath}/static/plugins/jquery.zoom/css/zoom.css" media="all"></link>
	<style>
	.gallery li a,.gallery li img{float:left;}
	<#if order.orderFollowStatus == 1>
		.rating-container{
			height:26px;
			line-height:34px;
		}
	<#else>
		.rating-container{
			height:26px;
			line-height:27px;
		}
	</#if>
		.star-rating{
			margin-top:4px;
		}
		.orderTable td{
			padding-left:43px;
		}
		.orderTable img{
			width:200px;
			height:150px;
		}
		.iOrderTable{
			width:100%;
		}
		.iOrderTable td{
			padding-left:0px;
		}
		.iOrderTable div{
			display:inline
		}
		.caret{
			white-space:nowrap;
		}
	</style>
</head>
	
<body>	
<div class="ms-content">
				<div class="ms-content-body" style="width: 100%;">
	<@ms.contentNav title="订单详情">
		<#if order.orderStatus == 1>
			<!-- 待审核 -->
			<button type="button" class="btn btn-primary" style="width:80px;" data-toggle="modal" data-target="#checkModel">审核</button>
			<button type="button" class="btn btn-success disabled" style="width:80px;">回访</button>
			<button type="button" class="btn btn-danger" style="width:80px;" data-toggle="modal" data-target="#cancelModel">取消订单</button>
		<#elseif order.orderStatus == 2>
			<!-- 待确认 -->
			<button type="button" class="btn btn-primary disabled" style="width:80px;">审核</button>
			<button type="button" class="btn btn-success disabled" style="width:80px;">回访</button>
			<button type="button" class="btn btn-danger" style="width:80px;" data-toggle="modal" data-target="#cancelModel">取消订单</button>
		<#elseif order.orderStatus == 3>
			<!-- 待维修 -->
			<button type="button" class="btn btn-primary disabled" style="width:80px;">审核</button>
			<#if order.orderFollowStatus == 0>
				<button type="button" class="btn btn-success" style="width:80px;" data-toggle="modal" data-target="#followModel">回访</button>
			<#else>
				<button type="button" class="btn btn-success disabled" style="width:80px;">回访</button>
			</#if>
			<button type="button" class="btn btn-danger" style="width:80px;" data-toggle="modal" data-target="#cancelModel">取消订单</button>
		<#elseif order.orderStatus == 4>
			<!-- 待评价 -->
			<button type="button" class="btn btn-primary disabled" style="width:80px;">审核</button>
			<#if order.orderFollowStatus == 0>
				<button type="button" class="btn btn-success" style="width:80px;" data-toggle="modal" data-target="#followModel">回访</button>
			<#else>
				<button type="button" class="btn btn-success disabled" style="width:80px;">回访</button>
			</#if>
			<button type="button" class="btn btn-danger disabled" style="width:80px;">取消订单</button>
		<#elseif order.orderStatus == 5>
			<!-- 已完成 -->
			<button type="button" class="btn btn-primary disabled" style="width:80px;">审核</button>
			<#if order.orderFollowStatus == 0>
				<button type="button" class="btn btn-success" style="width:80px;" data-toggle="modal" data-target="#followModel">回访</button>
			<#else>
				<button type="button" class="btn btn-success disabled" style="width:80px;">回访</button>
			</#if>
			<button type="button" class="btn btn-danger disabled" style="width:80px;">取消订单</button>
		<#else>
			<!-- 已关闭 -->
			<button type="button" class="btn btn-primary disabled" style="width:80px;">审核</button>
			<button type="button" class="btn btn-success disabled" style="width:80px;">回访</button>
			<button type="button" class="btn btn-danger disabled" style="width:80px;">取消订单</button>
		</#if>
		<@ms.button class="btn btn-default refresh" style="width:80px;" value="刷新" />
		<@ms.button class="btn btn-default returnList" style="width:80px;" value="返回列表" />
	</@ms.contentNav>
	<@ms.contentPanel>
				<table style="width:100%" class="orderTable">
					<tr style="height:40px;">
						<th colspan="2"><span style="background-color: palevioletred;margin-left:10px;">&nbsp;</span><span style="margin-left:10px;">订单信息</span></th>
					</tr>
					<tr>
						<td width="50%">订单编号：${order.orderCode}</td>
						<td width="50%">订单状态：<#if order.orderStatus == 1>待审核<#elseif order.orderStatus == 2>待确认<#elseif order.orderStatus == 3>待维修<#elseif order.orderStatus == 4>待评价<#elseif order.orderStatus == 5>已完成<#elseif order.orderStatus == 6>已关闭</#if></td>
					</tr>
					<#if order.orderStatus == 6>
					<tr>
						<td width="50%">取消原因：${order.orderCancelReason?default("")}</td>
						<td width="50%"><#if order.orderCancelRemark??>说明：${order.orderCancelRemark?default("")}</#if></td>
					</tr>
					</#if>
					<tr>
						<td colspan="2" style="padding-left:0px;padding-right:43px">
						<#if order.orderStatus == 6>
							<ul class="nav nav-pills nav-justified step step-square" style="margin-left:-42px;">
								<#if order.orderCreateTime??>
								<li class="active">
									<a>创建<span class="caret">${order.orderCreateTime?string("yyyy-MM-dd HH:mm:ss")}</span></a>
								</li>
								</#if>
								<#if order.orderCheckTime??>
								<li class="active">
									<a>审核<span class="caret">${order.orderCheckTime?string("yyyy-MM-dd HH:mm:ss")}<br/>(${order.orderCheckManager})</span></a>
								</li>
								</#if>
								<#if order.orderConfirmTime??>
								<li class="active">
									<a>确认<span class="caret">${order.orderConfirmTime?string("yyyy-MM-dd HH:mm:ss")}</span></a>
								</li>
								</#if>
								<#if order.orderCancelTime??>
								<li class="active">
									<a>取消<span class="caret">${order.orderCancelTime?string("yyyy-MM-dd HH:mm:ss")}</span></a>
								</li>
								</#if>
							</ul>
						<#else>		
							<ul class="nav nav-pills nav-justified step step-square" style="margin-left:-42px;">
								<li <#if order.orderCreateTime??>class="active"</#if>>
									<a>创建<#if order.orderCreateTime??><span class="caret">${order.orderCreateTime?string("yyyy-MM-dd HH:mm:ss")}</span></#if></a>
								</li>
								<li <#if order.orderCheckTime??>class="active"</#if>>
									<a>审核<#if order.orderCheckTime??><span class="caret">${order.orderCheckTime?string("yyyy-MM-dd HH:mm:ss")}<br/>(${order.orderCheckManager?default("")})</span></#if></a>
								</li>
								<li <#if order.orderConfirmTime??>class="active"</#if>>
									<a>确认<#if order.orderConfirmTime??><span class="caret">${order.orderConfirmTime?string("yyyy-MM-dd HH:mm:ss")}</span></#if></a>
								</li>
								<li <#if order.orderSignTime??>class="active"</#if>>
									<a>竣工<#if order.orderSignTime??><span class="caret">${order.orderSignTime?string("yyyy-MM-dd HH:mm:ss")}</span></#if></a>
								</li>
								<li <#if order.orderCommentTime??>class="active"</#if>>
									<a>评价<#if order.orderCommentTime??><span class="caret">${order.orderCommentTime?string("yyyy-MM-dd HH:mm:ss")}</span></#if></a>
								</li>
							</ul>
						</#if>
						</td>
					</tr>
					<tr style="height:40px;">
						<th colspan="2"><span style="background-color: blue;margin-left:10px;">&nbsp;</span><span style="margin-left:10px;">客户及车辆</span></th>
					</tr>
					<tr>
						<td >联系人：${order.orderContact?default("")}</td>
						<td >联系电话：${order.orderContactPhone?default("")}</td>
					</tr>
					<tr>
						<td >车牌号：${order.carPlateNumber?default("")}</td>
						<td >车辆型号：${order.carBrand?default("")}${order.carModel?default("")}</td>
					</tr>
					<tr>
						<td >购车价格：${order.carBuyPrice?default("")}</td>
						<td >购车日期：${order.carBuyDate?default("")}</td>
					</tr>
						<tr style="height:40px;">
						<th colspan="2"><span style="background-color: green;margin-left:10px;">&nbsp;</span><span style="margin-left:10px;">服务单位</span></th>
					</tr>
					<tr>
						<td >名称：${order.enterpriseName?default("")}</td>
						<td >地址：${order.enterpriseAddress?default("")}</td>
					</tr>
					<tr>
						<td >联系人：${order.enterpriseContact?default("")}</td>
						<td >联系电话：${order.enterpriseTel?default("")}</td>
					</tr>
					<tr style="height:40px;">
						<th colspan="2"><span style="background-color: maroon;margin-left:10px;">&nbsp;</span><span style="margin-left:10px;">服务及费用</span></th>
					</tr>
					<tr>
						<td>服务项目：${order.orderGoods?default("")}</td>
						<td><#if order.orderAppointTime??>预约时间：${order.orderAppointTime?string("yyyy-MM-dd HH:mm:ss")}<#else></#if></td>
					</tr>
					<tr>
						<td>预估金额：<span style="color:red;font-weight:bold"><#if order.orderTotalAmount??>#{order.orderTotalAmount;m2M2}</#if></span></td>
						<td><#if order.orderReceiveAmount??>实收金额：<span style="color:red;font-weight:bold">#{order.orderReceiveAmount;m2M2}</span></#if></td>
					</tr>
					<#if order.orderImages??>
					<tr>
						<td colspan="2">
						<ul class="gallery" style="margin-bottom:84px;">
						<#list order.orderImages as orderImage>
							<li><a href="${orderImage}"><img src="${orderImage}" class="img-thumbnail"/></a></li>
						</#list>
						</ul>
						</td>
					</tr>
					</#if>
					<#if order.orderCommentStatus == 1>
					</tr>
						<tr style="height:40px;">
						<th colspan="2"><span style="background-color: darkorange;margin-left:10px;">&nbsp;</span><span style="margin-left:10px;">服务评价</span></th>
					</tr>
					<#if comment??>
					<tr>
						<td colspan="2">
							<table class="iOrderTable" style="box-shadow:none;">
								<tr>
									<td>评分：<input id="rating-commentScore" type="number" value="${comment.commentScore}"/></td>
								</tr>
								<tr>
									<td><#if comment.commentContent??>评价内容：${comment.commentContent}</#if></td>
								</tr>
							</table>
						</td>
					</tr>
					</#if>
					</#if>
					<#if order.orderFollowStatus == 1>
					</tr>
					<tr style="height:40px;">
						<th colspan="2"><span style="background-color: DarkTurquoise;margin-left:10px;">&nbsp;</span><span style="margin-left:10px;">回访信息</span></th>
					</tr>
					<#if follow??>
					<tr>
						<td colspan="2">
							<table class="iOrderTable" style="box-shadow:none;">
								<tr>
									<td width="25%">维修质量：<input id="rating-followQualityScore" type="number" value="${follow.followQualityScore}"/></td>
									<td width="25%">服务态度：<input id="rating-followAttitudeScore" type="number" value="${follow.followAttitudeScore}"/></td>
									<td width="25%">维修价格：<input id="rating-followPriceScore" type="number" value="${follow.followPriceScore}"/></td>
									<td width="25%">总体评分：<input id="rating-followTotalScore" type="number" value="${follow.followTotalScore}"/></td>
								</tr>
								<#if follow.followRemark??>
								<tr>
									<td colspan="2">意见反馈：${follow.followRemark}</td>
									<td>回访人：${follow.followManager}</td>
									<td>回访时间：<#if follow.followTime??>${follow.followTime?string("yyyy-MM-dd HH:mm:ss")}</#if></td>
								</tr>
								</#if>
							</table>
						</td>
					</tr>
					</#if>
					</#if>
					<tr style="height:40px;">
					</tr>
				</table> 
	
<!--=================模态框部分开始=================-->
		<!--订单审核模态框开始-->
		<@ms.modal modalName="checkModel" title="订单审核">
			  <@ms.modalBody>
			  		确认审核通过？
		     </@ms.modalBody>
			 <@ms.modalButton>
		 		<@ms.savebutton id="checkButton" value="确定"/>
		 	</@ms.modalButton>
		</@ms.modal>
		<!--订单审核模态框结束-->
		<!--订单取消模态框开始-->
		<@ms.modal modalName="cancelModel" title="订单取消" size="M">
			<@ms.modalBody >
			<@ms.form isvalidation=true name="updateCancel" action="">
				<@ms.hidden name="orderCode" value="${order.orderCode}" />	
				<@ms.select name="orderCancelReason" label="取消原因：" default="请选择取消原因" list=cancelReasonList  listValue="value"   listKey="key" value="" validation={"required":"true", "data-bv-notempty-message":"必选项目"}/>
				<@ms.textarea name="orderCancelRemark" label="说明：" placeholder="请填写取消说明" rows="4" validation={"maxlength":"200"}/>
			 </@ms.form>	
		     </@ms.modalBody>
		     <@ms.modalButton>
		      	<@ms.savebutton id="cancelButton" value="取消订单"/> 
	    		<@ms.button value="关闭" id="closeOrderCancelModel"/>  
	 		 </@ms.modalButton>
		</@ms.modal>
		<!--订单取消模态框结束-->
		<!--回访模态框开始-->
		<@ms.modal modalName="followModel" title="回访" size="M">
			<@ms.modalBody >
			<@ms.form isvalidation=true name="updateFollow" action="">
				<@ms.hidden name="orderCode" value="${order.orderCode}" />	
				<#if order.orderSignStatus == 0>
				<@ms.date name="orderSignTime" label="竣工时间：" single=true time=true readonly="readonly" width="75%" value="${now?string('yyyy-MM-dd HH:mm:ss')}" validation={"required":"true", "data-bv-notempty-message":"必填项目"} placeholder="点击该框选择时间段"  />
				</#if>
				<@ms.text name="receiveAmount" label="实收金额：" placeholder="请输入实收金额" validation={"required":"true","data-bv-notempty-message":"必填项目","data-bv-regexp":"true", "data-bv-regexp-regexp":"^\\d+(\\.\\d{2})?$","data-bv-regexp-message":"格式错误"}/>
				<div class="form-group ms-form-group">
				<label for="followQualityScoreP" class="col-sm-3  control-label ">维修质量：</label>
				<div class="col-sm-9 ms-from-group-input ms-form-input" style="">	
				<input id="followQualityScoreP" type="number" class="rating" min=0 max=5 step=1 data-size="xs" >
				<@ms.hidden id="followQualityScore" name="followQualityScore" value="0" />	
				</div>
				</div>
				<div class="form-group ms-form-group">
				<label for="followAttitudeScoreP" class="col-sm-3  control-label ">服务态度：</label>
				<div class="col-sm-9 ms-from-group-input ms-form-input" style="">	
				<input id="followAttitudeScoreP" type="number" class="rating" min=0 max=5 step=1 data-size="xs" >
				<@ms.hidden id="followAttitudeScore" name="followAttitudeScore" value="0" />	
				</div>
				</div>
				<div class="form-group ms-form-group">
				<label for="followPriceScoreP" class="col-sm-3  control-label ">维修价格：</label>
				<div class="col-sm-9 ms-from-group-input ms-form-input" style="">	
				<input id="followPriceScoreP" type="number" class="rating" min=0 max=5 step=1 data-size="xs" >
				<@ms.hidden id="followPriceScore" name="followPriceScore" value="0" />	
				</div>
				</div>
				<div class="form-group ms-form-group">
				<label for="followTotalScoreP" class="col-sm-3  control-label ">总体评分：</label>
				<div class="col-sm-9 ms-from-group-input ms-form-input" style="">	
				<input id="followTotalScoreP" type="number" class="rating" min=0 max=5 step=1 data-size="xs" >
				<@ms.hidden id="followTotalScore" name="followTotalScore" value="0" />	
				</div>
				</div>
				<@ms.textarea name="followRemark" label="意见反馈：" placeholder="请填写意见反馈" rows="4" validation={"maxlength":"200"}/>
			 </@ms.form>	
		     </@ms.modalBody>
		     <@ms.modalButton>
		      	<@ms.savebutton id="followButton" value="提交"/> 
	    		<@ms.button value="关闭" id="closeOrderFollowModel"/>  
	 		 </@ms.modalButton>
		</@ms.modal>
		</@ms.contentPanel>
		</div>
		</div>
	</body>
</html>
		<!--回访模态框结束-->
		<!--=================模态框部分结束=================-->
	<script>
		$(function(){
			$("form[name='updateCancel']").parent().css("height","250px");
			$("form[name='updateFollow']").parent().css("height","460px");
			$('#rating-followAttitudeScore').rating({
              min: 0,
              max: 5,
              step: 1,
              size: 'xs',
              readonly: true,
              showClear: false
           });
           $('#rating-followQualityScore').rating({
              min: 0,
              max: 5,
              step: 1,
              size: 'xs',
              readonly: true,
              showClear: false
           });
           $('#rating-followPriceScore').rating({
              min: 0,
              max: 5,
              step: 1,
              size: 'xs',
              readonly: true,
              showClear: false
           });
           $('#rating-followTotalScore').rating({
              min: 0,
              max: 5,
              step: 1,
              size: 'xs',
              readonly: true,
              showClear: false
           });
		   $('#rating-commentScore').rating({
              min: 0,
              max: 5,
              step: 1,
              size: 'xs',
              readonly: true,
              showClear: false
           });
			
			//$('input[name="orderSignTime"]').daterangepicker({
			//	timePicker: true,
			//  });
			
			//审核订单
			$("#checkButton").click(function() {
			$.ajax({
				type: "post",
				dataType: "json",
				url: base+"${baseManager}/order/check.do",
				data:"orderCode=${order.orderCode}",
				beforeSend:function() {
					$("#checkButton").text("审核中");
					$("#checkButton").attr("disabled",true);
		 		},
		 		success: function(msg){
					if(msg.result){
						alert("订单审核成功");
	   					location.reload();
					} else {
						if(msg.code=="941"){
							alert("订单审核失败，订单状态不正确");
							location.reload();
						}else if(msg.code=="500"){
							alert("订单审核失败，系统异常");
							$("#checkButton").text("确定");
							$("#checkButton").attr("disabled",false);
						}
					}
				},
				error:function(){
					alert("订单审核失败，请刷新重试");
					$("#checkButton").text("确定");
					$("#checkButton").attr("disabled",false);
				}
			});
			});
			
			//点击取消订单按钮
	 		$("#cancelButton").click(function() {
	 		var vobj = $("#updateCancel").data('bootstrapValidator').validate();
	 		if(vobj.isValid()){
	 		if(!confirm("确认取消订单？")){
					return false;
			}
			$.ajax({
				type: "post",
				dataType: "json",
				url: base+"${baseManager}/order/cancel.do",
				data:$("#updateCancel").serialize(),
				beforeSend:function() {
					$("#cancelButton").text("取消中");
					$("#cancelButton").attr("disabled",true);
		 		},
		 		success: function(msg){
					if(msg.result){
						alert("订单取消成功");
	   					location.reload();
					} else {
						if(msg.code=="941"){
							alert("订单取消失败，订单状态不正确");
							location.reload();
						}else if(msg.code=="500"){
							alert("订单取消失败，系统异常");
							$("#cancelButton").text("取消订单");
							$("#cancelButton").attr("disabled",false);
						}
					}
				},
				error:function(){
					alert("订单取消失败，请刷新重试");
					$("#cancelButton").text("取消订单");
					$("#cancelButton").attr("disabled",false);
				}
			});}
			});
			$("#closeOrderCancelModel").click(function(){
				$(".cancelModel").modal("hide");//关闭
			});
			
			//点击取消订单按钮
	 		$("#followButton").click(function() {
	 		var vobj = $("#updateFollow").data('bootstrapValidator').validate();
	 		if(vobj.isValid()){
	 		if($('#followAttitudeScore').val()==0||$('#followQualityScore').val()==0||$('#followPriceScore').val()==0||$('#followTotalScore').val()==0){
	 			alert("请先评分");
	 			return false;
	 		}
	 		if(!confirm("确认提交回访？")){
				return false;
			}
			$.ajax({
				type: "post",
				dataType: "json",
				url: base+"${baseManager}/order/follow.do",
				data:$("#updateFollow").serialize(),
				beforeSend:function() {
					$("#followButton").text("提交中");
					$("#followButton").attr("disabled",true);
		 		},
		 		success: function(msg){
					if(msg.result){
						alert("提交回访成功");
	   					location.reload();
					} else {
						if(msg.code=="941"){
							alert("提交回访失败，订单状态不正确");
							location.reload();
						}else if(msg.code=="500"){
							alert("提交回访失败，系统异常");
							$("#followButton").text("提交");
							$("#followButton").attr("disabled",false);
						}
					}
				},
				error:function(){
					alert("提交回访失败，请刷新重试");
					$("#followButton").text("提交");
					$("#followButton").attr("disabled",false);
				}
			});}
			});
			$("#closeOrderFollowModel").click(function(){
				$(".followModel").modal("hide");//关闭
			});
			
			$('#followAttitudeScoreP').on('rating.change', function(event, value, caption) {
    			$('#followAttitudeScore').val(value);
			});
			$('#followAttitudeScoreP').on('rating.clear', function(event) {
    			$('#followAttitudeScore').val(0);
			});
			
			$('#followQualityScoreP').on('rating.change', function(event, value, caption) {
    			$('#followQualityScore').val(value);
			});
			$('#followQualityScoreP').on('rating.clear', function(event) {
    			$('#followQualityScore').val(0);
			});
			
			$('#followPriceScoreP').on('rating.change', function(event, value, caption) {
    			$('#followPriceScore').val(value);
			});
			$('#followPriceScoreP').on('rating.clear', function(event) {
    			$('#followPriceScore').val(0);
			});
			
			$('#followTotalScoreP').on('rating.change', function(event, value, caption) {
    			$('#followTotalScore').val(value);
			});
			$('#followTotalScoreP').on('rating.clear', function(event) {
    			$('#followTotalScore').val(0);
			});
			//返回栏目列表
			$(".returnList").click(function(){
				location.href = "${managerPath}/order/list.do?${params}";
			});
			$(".refresh").click(function(){
				window.location.reload();
			});
		});
		
	</script>
	<script type="text/javascript" src="${basePath}/static/plugins/jquery.zoom/js/zoom.min.js"></script>	